﻿@model RegionEditGetViewModel
@{
    ViewBag.Title = "编辑区域";
}

<article class="page-container">
    <form class="form form-horizontal" id="form-admin-add">
        <input type="hidden" name="id" value="@Model.Region.Id" />
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">城市：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box" style="width:150px;">
                    <select class="select" name="selectCity" size="1">
                        @foreach (var city in Model.AllCities)
                        {
                            <option value="@city.Id" selected="@Model.Region.CityId.Equals(city.Id)">@city.Name</option>
                        }
                    </select>
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>区域名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Region.Name" placeholder="" id="name" name="name">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

@section FooterScript
{
    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="~/Areas/WebAdmin/FrontLib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="~/Areas/WebAdmin/FrontLib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="~/Areas/WebAdmin/FrontLib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript">
$(function(){
	$("#form-admin-add").validate({
		rules:{
		    name: {
		        required: true
		    }
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
		    $(form).ajaxSubmit({
		        type: 'POST',
		        url: "/WebAdmin/Region/Edit",
		        success: function (res) {
		            if (res.status == "ok") {
		                parent.layer.msg('修改成功!', { icon: 1, time: 1000 }, function () {
		                    parent.$('.btn-refresh').click();
		                    //parent.location.reload(); //刷新父页面
		                    var index = parent.layer.getFrameIndex(window.name);
		                    parent.layer.close(index);
		                });
		            } else if (res.status == "redirect") {
		                location.href = res.data;
		            } else if (res.status == "error") {
		                layer.msg(res.errorMsg, { icon: 2, time: 1000 });
		            }else {
		                layer.msg("修改失败", { icon: 2, time: 1000 });
		            }
		        },
		        error: function (XmlHttpRequest, textStatus, errorThrown) {
		            layer.msg('网络出错!', { icon: 2, time: 1000 });
		        }
		    });
		}
	});
});
    </script>
    <!--/请在上方写此页面业务相关的脚本-->
}


